package com.shemy.fileservice.domain.es;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.Id;
import java.util.Date;

/**
 * @Description esFile
 * @Author Dzsom
 * @Date 2018-10-31 21:46
 * @Encoding UTF-8
 * @Version 1.0
 **/
@Document(indexName = "file",type = "document")
@NoArgsConstructor
@Getter
@Setter
public class FileEntityEs {
    @Id  // 主键
    private String id;
    private String name;
    private String contentType;
    private long size;
    private Date uploadDate;
    private String md5;
    private String path;
    private String ipAddress;

    public FileEntityEs(String id, String name, String contentType,String path, long size) {
        this.id=id;
        this.name = name;
        this.contentType = contentType;
        this.path=path;
        this.size = size;
        this.uploadDate = new Date();
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (object == null || getClass() != object.getClass()) {
            return false;
        }
        FileEntityEs fileInfo = (FileEntityEs) object;
        return java.util.Objects.equals(size, fileInfo.size)
                && java.util.Objects.equals(name, fileInfo.name)
                && java.util.Objects.equals(contentType, fileInfo.contentType)
                && java.util.Objects.equals(uploadDate, fileInfo.uploadDate)
                && java.util.Objects.equals(md5, fileInfo.md5)
                && java.util.Objects.equals(id, fileInfo.id);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(name, contentType, size, uploadDate, md5, id);
    }

    @Override
    public String toString() {
        return "File{"
                + "name='" + name + '\''
                + ", contentType='" + contentType + '\''
                + ", size=" + size
                + ", uploadDate=" + uploadDate
                + ", md5='" + md5 + '\''
                + ", id='" + id + '\''
                + '}';
    }
}
